package org.ohuang

import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream

fun readText(file:File):String{
    var fileInputStream = FileInputStream(file)
    return fileInputStream.use {
        var readBytes = it.readBytes()
        String(readBytes)
    }

}

fun writeText(file: File,text:String){
    if (!file.parentFile.exists()){
        file.parentFile.mkdirs()
    }
    var fileOutputStream = FileOutputStream(file)
    fileOutputStream.use {
        var encodeToByteArray = text.encodeToByteArray()
        it.write(encodeToByteArray)
    }

}